package com.core.zyyz.pcmc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.core.zyyz.pcmc.domain.PcmcChannel;
import com.core.zyyz.pcmc.service.PcmcChannelService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.common.utils.poi.ExcelUtil;
import com.core.common.core.page.TableDataInfo;

/**
 * 渠道Controller
 *
 * @author core
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/pcmc/channel")
public class PcmcChannelController extends BaseController
{
    @Autowired
    private PcmcChannelService pcmcChannelService;

    /**
     * 查询渠道列表
     */
    @PreAuthorize("@ss.hasPermi('system:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(PcmcChannel pcmcChannel)
    {
        startPage();
        List<PcmcChannel> list = pcmcChannelService.selectPcmcChannelList(pcmcChannel);
        return getDataTable(list);
    }

    /**
     * 获取渠道详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:channel:query')")
    @GetMapping(value = "/{channelId}")
    public AjaxResult getInfo(@PathVariable("channelId") String channelId)
    {
        return success(pcmcChannelService.selectPcmcChannelByChannelId(channelId));
    }

    /**
     * 新增渠道
     */
    @PreAuthorize("@ss.hasPermi('system:channel:add')")
    @Log(title = "渠道", businessType = BusinessType.INSERT)
    @PostMapping("/insertChannel")
    public AjaxResult add(@RequestBody PcmcChannel pcmcChannel)
    {
        return toAjax(pcmcChannelService.insertPcmcChannel(pcmcChannel));
    }

    /**
     * 修改渠道
     */
    @PreAuthorize("@ss.hasPermi('system:channel:edit')")
    @Log(title = "渠道", businessType = BusinessType.UPDATE)
    @PostMapping("/updateChannel")
    public AjaxResult edit(@RequestBody PcmcChannel pcmcChannel)
    {
        return toAjax(pcmcChannelService.updatePcmcChannel(pcmcChannel));
    }

    /**
     * 删除渠道
     */
    @PreAuthorize("@ss.hasPermi('system:channel:remove')")
    @Log(title = "渠道", businessType = BusinessType.DELETE)
    @DeleteMapping("/{channelIds}")
    public AjaxResult remove(@PathVariable String[] channelIds)
    {
        return toAjax(pcmcChannelService.deletePcmcChannelByChannelIds(channelIds));
    }
}
